<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .totast {
      position: fixed;
      bottom: 20px;
      left: 50%;
      font-size: 12px;
      transform: translate3d(-50%, 0, 0);
      padding: 4px 10px;
      border-radius: 5px;
      font-style: normal;
      color: #fff;
      background: rgba(0,0,0,0.7);
      animation: totast 1s 2 alternate;
    }
    
    @keyframes totast {
      0% {
        opacity: 0;
      }
      100% {
        opacity: 1;
      }
    }
  </style>
</head>
<body>
  <!-- <i class="totast">内容</i> -->

  <script src="./totast.js"></script>
  <script>
    /* var totast = document.querySelector('.totast')
    totast.addEventListener('animationiteration', function () {
      this.style.animationPlayState = 'paused'
      var _this = this
      setTimeout(function () {
        _this.style.animationPlayState = 'running'
      }, 2000)
    })

    totast.addEventListener('animationend', function () {
      this.parentNode.removeChild(this)

    }) */

    document.onclick = function () {
      totast('测试内容')
    }

  </script>

</body>
</html>